<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm" style="padding-bottom: 300px!important;">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">


        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>工程信息</span><span onclick="go_to_engin_xiang()" class="colorlan" style="float: right;margin-right: 12px">查看工程概况</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enginid" class="layui-input enginid" onclick="openPage('../public/choose_engin.php?dom=enginid&page=piao_kai','80%','80%')">
                            <div class="choose_div" id="enginid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin.php?dom=enginid&page=piao_kai','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_number" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">业务归属</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_gui_unit_name" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程管理文件汇编</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_neiname" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程负责人</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_gofuer" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程负责人联系电话</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_gofutel" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">中标价(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_winfee" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程结算金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="engin_shijiefee" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>销售方信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>开票单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=kaier&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="kaier"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=kaier&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="kaier_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>销售方账户名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="kai_zhangname" class="layui-input kai_zhangname" onclick="choose_account()">
                            <div class="choose_div" id="kai_zhangname" key="1"></div>
                            <span class="choose_one" onclick="choose_account()"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">销售方开户银行</label>
                        <div class="layui-input-block">
                            <input type="text" name="kai_bankname" id="kai_bankname" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">销售方银行账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="kai_banknum" id="kai_banknum" readonly placeholder="请输入" autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>购买方信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>发包方(购买方)单位名称</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="shouer" class="layui-input shouer" onclick="openPage('../public/choose_dealcom.php?dom=shouer&page=piao_kai','80%','80%')">
                            <div class="choose_div" id="shouer" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=shouer&page=piao_kai','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>纳税人识别号</label>
                        <div class="layui-input-block">
                            <input type="text" name="ratenum" id="ratenum" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开户行</label>
                        <div class="layui-input-block">
                            <input type="text" name="bankname" id="bankname" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="banknum" id="banknum" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="unitaddr" id="unitaddr" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" id="phone" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>





            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>发票信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>本次开票金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="money" id="money" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>是否红冲</label>
                        <div class="layui-input-block">
                            <select id="ishong" name="ishong" lay-filter="ishong">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="ishong_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide hongshuo">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">红冲原因说明</label>
                        <div class="layui-input-block">
                            <input type="text" name="hongshuo" id="hongshuo" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">上期累计开票金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="leikaifee" name="leikaifee" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">截止本次累计开票金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="jiebenfee" name="jiebenfee" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">截止本次累计开票占比(%)</label>
                        <div class="layui-input-block">
                            <input type="text" id="jiebenrate" name="jiebenrate" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>票款方式</label>
                        <div class="layui-input-block">
                            <div id="kuantype"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>发票类型</label>
                        <div class="layui-input-block">
                            <div id="qianpiaotype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>税率</label>
                        <div class="layui-input-block">
                            <div id="shuilv"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">服务内容</label>
                        <div class="layui-input-block">
                            <div id="funei"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">发票备注-工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="bei_gong" id="bei_gong" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">发票备注-工程地点</label>
                        <div class="layui-input-block">
                            <input type="text" name="bei_addr" id="bei_addr" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">发票备注-特殊要求</label>
                        <div class="layui-input-block">
                            <input type="text" name="bei_yao" id="bei_yao" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联流程</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>


        <div class="block-generic hongshi">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>本次税款保证金信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>是否收取税款保证金</label>
                        <div class="layui-input-block">
                            <select id="isshou" name="isshou" lay-filter="isshou">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="isshou_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-hide isshoushi">
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label"><text>*</text>税款保证金收取方式</label>
                            <div class="layui-input-block">
                                <select id="shuishou" name="shuishou" lay-filter="shuishou">
                                    <option value="1">开票已预缴</option>
                                    <option value="2">回款待收取</option>
                                </select>
                                <p class="error" id="shuishou_error" style="margin: 0;"></p>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item shuishou11">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label"><text>*</text>关联收取</label>
                            <div class="layui-input-block">
                                <input type="text" readonly name="kouids" class="layui-input kouids" onclick="choose_koushou()">
                                <div class="choose_div" id="kouids" key="1"></div>
                                <span class="choose_one" onclick="choose_koushou()"><i class="layui-icon layui-icon-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item shuishou22 layui-hide">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label"><text>*</text>税款承诺书</label>
                            <div class="layui-input-block">
                                <input type="text" readonly name="shuiid" class="layui-input shuiid" onclick="choose_engin_shui()">
                                <div class="choose_div" id="shuiid" key="1"></div>
                                <span class="choose_one" onclick="choose_engin_shui()"><i class="layui-icon layui-icon-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12">
                            <label class="layui-form-label">税款保证金金额(元)</label>
                            <div class="layui-input-block">
                                <input type="text" name="koufee" id="koufee" disabled placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput disabled">
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <div class="block-generic hongshi">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>跨区域涉税事项信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>开具跨区域涉税事项表</label>
                        <div class="layui-input-block">
                            <select id="iskaishe" name="iskaishe" lay-filter="iskaishe">
                                <option value="">请选择</option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                            <p class="error" id="iskaishe_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">跨区域涉税事项报验管理有效日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="shedt" id="shedt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程所在地本次已交外管税(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="waifee" id="waifee" placeholder="请输入" autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">工程所在地涉税事项核销</label>
                        <div class="layui-input-block">
                            <input type="text" name="gongxiao" id="gongxiao" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">公司所在地涉税事项核销</label>
                        <div class="layui-input-block">
                            <input type="text" name="sixiao" id="sixiao" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">外管税缴纳方式</label>
                        <div class="layui-input-block">
                            <select id="waijiao" name="waijiao" lay-filter="waijiao"></select>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    var param_isturn = getQueryVariable('isturn') || 0;
    if(param_isturn > 0){
        $("#billzhan").remove();
        $("#billtutn").remove();
        $("#billsub").attr('isshen', 1);
    }
    var param_billyushen = getQueryVariable('billyushen') || 0;
    if(param_billyushen == 2){
        $("#billyushen").addClass('layui-hide');
    }

    $("#commentForm").validate({
        rules: {
            money: {required: true},
            ratenum: {required: true},
        },
        messages:{
            money: {required: "请输入"},
            ratenum: {required: "请输入"},
        }
    });

    function choose_account() {
        var kaier = tan_tags_getvalue("#kaier", 'dept');
        if(!kaier){
            facade.error("请先选择开票单位");return false;
        }
        openPage('../public/choose_account.php?dom=kai_zhangname&page=piao_kai_kaier&chanid='+kaier,'80%','80%')
    }

    function import_list() {
        openPage('../public/import.php?reveal=piao_kai@importdata', '770px', '490px');
    }


    function choose_koushou(){
        var enginid = get_choose_val('enginid');
        if(!enginid){
            facade.error("请先选择工程名称");return false;
        }
        openPage('koushou.php?dom=kouids&page=piao_kai&enginid='+enginid,'80%','80%');
    }
    function choose_engin_shui(){
        var enginid = get_choose_val('enginid');
        if(!enginid){
            facade.error("请先选择工程名称");return false;
        }
        openPage('engin_shui.php?dom=shuiid&page=piao_kai&enginid='+enginid,'80%','80%');
    }

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_flowdata_edit_piao_kai, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                    if(data.advaners_info.length > 0){
                        tan_tags_init('#advaners', data.advaners_info);
                    }
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                    if(data.nexter_info.length > 0){
                        tan_tags_init('#nexter', data.nexter_info);
                    }
                }
                if(data.flowrelas_info.length > 0){
                    set_choose_btn_more('flowrelas',data.flowrelas_info);
                }


                var engininfo = res.data.engininfo;
                if(engininfo){
                    set_choose_btn('enginid',engininfo.id,engininfo.name);
                    $('#engin_number').val(engininfo.number);
                    $('#engin_gui_unit_name').val(engininfo.gui_unit_name);
                    $('#engin_gofuer').val(engininfo.gofuer);
                    $('#engin_gofutel').val(engininfo.gofutel);
                    if(engininfo.neiinfo){
                        $('#engin_neiname').val(engininfo.neiinfo.name);
                    }
                    $('#engin_winfee').val(engininfo.winfee);
                }



                $("#number").val(data.number);
                $("#money").val(data.money);
                $("#leikaifee").val(data.leikaifee);
                $("#jiebenfee").val(data.jiebenfee);
                $("#jiebenrate").val(data.jiebenrate);
                $("#ratenum").val(data.ratenum);
                $("#bankname").val(data.bankname);
                $("#banknum").val(data.banknum);
                $("#unitaddr").val(data.unitaddr);
                $("#phone").val(data.phone);
                $("#ishong").val(data.ishong);
                $("#hongshuo").val(data.hongshuo);
                $("#dt").val(data.dt);
                $("#baner").val(data.baner);
                $("#funei").val(data.funei);
                $("#kaier").val(data.kaier);

                $("#bei_gong").val(data.bei_gong);
                $("#bei_addr").val(data.bei_addr);
                $("#bei_yao").val(data.bei_yao);
                $("#iskaishe").val(data.iskaishe);
                $("#shedt").val(data.shedt);
                $("#kai_bankname").val(data.kai_bankname);
                $("#kai_banknum").val(data.kai_banknum);
                $("#waifee").val(data.waifee);
                $("#gongxiao").val(data.gongxiao);
                $("#sixiao").val(data.sixiao);
                $("#explain").val(data.explain);
                $("#shuishou").val(data.shuishou);
                $("#isshou").val(data.isshou);


                if(data.kaier_info.length > 0){
                    tan_tags_init('#kaier', data.kaier_info);
                }

                if(data.kai_zhangname){
                    set_choose_btn('kai_zhangname',data.kai_zhangname,data.kai_zhangname);
                }

                if(data.shouer){
                    set_choose_btn('shouer',data.shouer,data.shouer);
                }





                if(data.ishong == '是'){
                    $(".hongshuo").removeClass('layui-hide');
                    $(".hongshi").addClass('layui-hide');
                }




                if(data.isshou == '是'){
                    $(".isshoushi").removeClass('layui-hide');
                }else{
                    $(".isshoushi").addClass('layui-hide');
                }

                if(data.shuishou == 1){
                    $(".shuishou11").removeClass('layui-hide');
                    $(".shuishou22").addClass('layui-hide');

                    set_choose_btn('kouids',data.kouids,data.kouids_name);
                    $("#koufee").val(data.koufee);
                }else{
                    $(".shuishou11").addClass('layui-hide');
                    $(".shuishou22").removeClass('layui-hide');

                    var shuiidinfo = res.data.shuiidinfo;
                    if(shuiidinfo){
                        set_choose_btn('shuiid',shuiidinfo.id,shuiidinfo.name);
                    }
                    $("#koufee").val(data.koufee);
                }






                xmselect_dan('qianpiaotype', res.data.qianpiaotype, data.qianpiaotype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#qianpiaotype").find('xm-select').removeClass('error');
                    }else{
                        $("#qianpiaotype").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('shuilv', res.data.shuilv, data.shuilv, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#shuilv").find('xm-select').removeClass('error');
                    }else{
                        $("#shuilv").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('kuantype', res.data.kuantype, data.kuantype, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#kuantype").find('xm-select').removeClass('error');
                    }else{
                        $("#kuantype").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('funei', res.data.funei, data.funei);

                var waijiao_str = '<option value="">请选择</option>';
                var waijiao = res.data.waijiao;
                for (var key in waijiao){
                    if(waijiao[key] == data.waijiao){
                        waijiao_str += '<option value="'+waijiao[key]+'" selected>'+waijiao[key]+'</option>';
                    }else{
                        waijiao_str += '<option value="'+waijiao[key]+'">'+waijiao[key]+'</option>';
                    }
                }
                $("#waijiao").html(waijiao_str);

                initParseMoney();
                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });

        form.on('select(ishong)', function(data){
            if(data.value == ''){
                $('#ishong_error').show().text('请选择');
                $('#ishong_error').parent().find('input').addClass('select_error');
            }else{
                $('#ishong_error').hide();
                $('#ishong_error').parent().find('input').removeClass('select_error');
            }

            if(data.value == '是'){
                $(".hongshuo").removeClass('layui-hide');
                $(".hongshi").addClass('layui-hide');
            }else{
                $(".hongshuo").addClass('layui-hide');
                $(".hongshi").removeClass('layui-hide');
            }

        });

        form.on('select(isshou)', function(data){
            if(data.value == ''){
                $('#isshou_error').show().text('请选择');
                $('#isshou_error').parent().find('input').addClass('select_error');
            }else{
                $('#isshou_error').hide();
                $('#isshou_error').parent().find('input').removeClass('select_error');
            }

            if(data.value == '是'){
                $(".isshoushi").removeClass('layui-hide');
            }else{
                $(".isshoushi").addClass('layui-hide');
            }

        });

        form.on('select(iskaishe)', function(data){
            if(data.value == ''){
                $('#iskaishe_error').show().text('请选择');
                $('#iskaishe_error').parent().find('input').addClass('select_error');
            }else{
                $('#iskaishe_error').hide();
                $('#iskaishe_error').parent().find('input').removeClass('select_error');
            }
        });

        form.on('select(shuishou)', function(data){
            if(data.value == ''){
                $('#shuishou_error').show().text('请选择');
                $('#shuishou_error').parent().find('input').addClass('select_error');
            }else{
                $('#shuishou_error').hide();
                $('#shuishou_error').parent().find('input').removeClass('select_error');
            }

            if(data.value == 1){
                $(".shuishou11").removeClass('layui-hide');
                $(".shuishou22").addClass('layui-hide');
            }else{
                $(".shuishou11").addClass('layui-hide');
                $(".shuishou22").removeClass('layui-hide');
            }

        });



        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');


            data.field.enginid = get_choose_val('enginid');
            data.field.kaier = tan_tags_getvalue("#kaier", 'dept');
            data.field.kai_zhangname = get_choose_val('kai_zhangname');
            data.field.shouer = get_choose_val('shouer');
            data.field.kouids = get_choose_val('kouids');
            data.field.shuiid = get_choose_val('shuiid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                formValid('enginid');
                if(data.field.enginid == undefined || !data.field.enginid){
                    validRes = false;
                }

                if(!data.field.kaier){
                    $("#kaier").parents('.tanxian').addClass('tanerror');
                    $('#kaier_tanerror').text('请选择');
                    validRes = false;
                }else{
                    $("#kaier").parents('.tanxian').removeClass('tanerror');
                    $('#kaier_tanerror').text('');
                }

                formValid('kai_zhangname');
                if(data.field.kai_zhangname == undefined || !data.field.kai_zhangname){
                    validRes = false;
                }

                formValid('shouer');
                if(data.field.shouer == undefined || !data.field.shouer){
                    validRes = false;
                }

                if(!data.field.qianpiaotype){
                    $("#qianpiaotype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#qianpiaotype").find('xm-select').removeClass('error');
                }

                if(!data.field.shuilv){
                    $("#shuilv").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#shuilv").find('xm-select').removeClass('error');
                }

                if(!data.field.kuantype){
                    $("#kuantype").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#kuantype").find('xm-select').removeClass('error');
                }

                if(data.field.ishong == ''){
                    $('#ishong_error').show().text('请选择');
                    $('#ishong_error').parent().find('input').addClass('select_error');
                    validRes = false;
                }else{
                    $('#ishong_error').hide();
                    $('#ishong_error').parent().find('input').removeClass('select_error');
                }



                if(data.field.ishong != '是'){
                    if(data.field.isshou == ''){
                        $('#isshou_error').show().text('请选择');
                        $('#isshou_error').parent().find('input').addClass('select_error');
                        validRes = false;
                    }else{
                        $('#isshou_error').hide();
                        $('#isshou_error').parent().find('input').removeClass('select_error');
                    }

                    if(data.field.isshou == '是'){
                        if(data.field.shuishou == 1){
                            formValid('kouids');
                            if(data.field.kouids == undefined || !data.field.kouids){
                                validRes = false;
                            }
                        }else{
                            formValid('shuiid');
                            if(data.field.shuiid == undefined || !data.field.shuiid){
                                validRes = false;
                            }
                        }
                    }
                    if(data.field.iskaishe == ''){
                        $('#iskaishe_error').show().text('请选择');
                        $('#iskaishe_error').parent().find('input').addClass('select_error');
                        validRes = false;
                    }else{
                        $('#iskaishe_error').hide();
                        $('#iskaishe_error').parent().find('input').removeClass('select_error');
                    }

                }





                if(!validRes){return false;}
            }



            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            data = parseMoney(data);

            public_flow_submit(data.field, ask_flowdata_add_piao_kai, ask_flowdata_edit_piao_kai, $(this).attr('but'));
            return false;
        });

    });


    $("#money,#leikaifee").on('input propertychange',function () {
        jisuan_jiebenrate();
    });
    function jisuan_jiebenrate(){
        var leikaifee = parseFloat($("#leikaifee").val() || 0) || 0;
        var money = parseValidNum($("#money").val());

        var jiebenfee = parseFloat(leikaifee) + parseFloat(money);
        $("#jiebenfee").val(parseFloat(jiebenfee).toFixed(2));

        var jiebenrate = 0;
        var engin_shijiefee = parseFloat($("#engin_shijiefee").val() || 0) || 0;
        var engin_winfee = parseFloat($("#engin_winfee").val() || 0) || 0;
        if(engin_shijiefee != 0){
            jiebenrate = parseFloat(jiebenfee / engin_shijiefee * 100);
        }else{
            if(engin_winfee != 0){
                jiebenrate = parseFloat(jiebenfee / engin_winfee * 100);
            }
        }
        $("#jiebenrate").val(parseFormatNum(jiebenrate,2));
    }



    function choose_enginid_delete() {

    }

    function go_to_engin_xiang(){
        var enginid = get_choose_val('enginid');
        if(!enginid){
            facade.error("请先选择工程名称");return false;
        }
        openPage('../engin/xiang.php?id='+enginid);
    }
</script>
</body>
</html>
